package jjn.carl.dp;

import java.util.Scanner;

/**
 * @author Jiang Jining
 * @since 2023-08-20 23:53
 */
public class LeetCode518 {
    public int change(int amount, int[] coins) {
        int[] dp = new int[amount + 1];
        dp[0] = 1;
        for (int i = 0; i < coins.length; i++) {
            for (int j = coins[i]; j <= amount; j++) {
                dp[j] += dp[j - coins[i]];
            }
        }
        return dp[amount];
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int amount = scanner.nextInt();
        int num = scanner.nextInt();
        int[] coins = new int[num];
        for (int i = 0; i < num; i++) {
            coins[i] = scanner.nextInt();
        }
        int count = new LeetCode518().change(amount, coins);
        System.out.println(count);
    }
}
